'ok',
'warning', 'delayed', 'degraded', 'pending', 'partial' => 'warn',
'offline', 'critical', 'blocked', 'failed' => 'bad',
default => 'neutral',
};
}
function avg(array $values): float
{
$values = array_filter($values, fn($v) => is_numeric($v));
if (count($values) === 0) {
return 0.0;
}
return array_sum($values) / count($values);
}
function clamp(float $value, float $min, float $max): float
{
return max($min, min($max, $value));
}
/* ---------------------------------
DEFAULT DATA
--------------------------------- */
$defaultProjects = [
'projects' => [
[
'name' => 'SIMON Intelligence Core',
'owner' => 'Keith',
'status' => 'active',
'priority' => 'high',
'completion' => 74,
'budget' => 18000,
'spent' => 9200,
'due_date' => '2026-04-15',
'phase' => 'Core Platform',
'todos_open' => 12,
'todos_done' => 34,
],
[
'name' => 'WEB360 Studio',
'owner' => 'Keith',
'status' => 'active',
'priority' => 'high',
'completion' => 68,
'budget' => 24000,
'spent' => 11750,
'due_date' => '2026-05-10',
'phase' => 'Builder Engine',
'todos_open' => 18,
'todos_done' => 29,
],
[
'name' => 'SIMON Social',
'owner' => 'Keith',
'status' => 'warning',
'priority' => 'medium',
'completion' => 38,
'budget' => 12000,
'spent' => 4100,
'due_date' => '2026-05-28',
'phase' => 'Social Automation',
'todos_open' => 21,
'todos_done' => 9,
],
[
'name' => 'Investor Relations Suite',
'owner' => 'Keith',
'status' => 'pending',
'priority' => 'medium',
'completion' => 22,
'budget' => 9000,
'spent' => 1800,
'due_date' => '2026-06-01',
'phase' => 'Reporting',
'todos_open' => 10,
'todos_done' => 5,
],
]
];
$defaultAccounting = [
'revenue_streams' => [
['name' => 'Books', 'amount' => 1200],
['name' => 'Art', 'amount' => 900],
['name' => 'Software / WEB360', 'amount' => 2200],
['name' => 'Services / Consulting', 'amount' => 1500],
],
'expenses' => [
['name' => 'Hosting', 'amount' => 125],
['name' => 'Domains', 'amount' => 48],
['name' => 'AI APIs', 'amount' => 420],
['name' => 'Design / Assets', 'amount' => 165],
['name' => 'Marketing', 'amount' => 280],
],
'cash_on_hand' => 1330,
'monthly_recurring' => 2400,
'outstanding_debt' => 6300
];
$defaultAnalytics = [
'traffic' => [
'visits_today' => 189,
'visits_7d' => 1320,
'visits_30d' => 5840,
'bounce_rate' => 36.4,
'conversion_rate' => 4.2,
'avg_session_minutes' => 3.8,
],
'channels' => [
['name' => 'Organic', 'visits' => 2140],
['name' => 'Direct', 'visits' => 1380],
['name' => 'Social', 'visits' => 1170],
['name' => 'Referral', 'visits' => 650],
['name' => 'Paid', 'visits' => 500],
],
'top_pages' => [
['path' => '/web360/', 'views' => 1240],
['path' => '/simon/', 'views' => 1115],
['path' => '/books/', 'views' => 760],
['path' => '/art/', 'views' => 605],
['path' => '/infinity/', 'views' => 480],
]
];
$defaultSystem = [
'modules' => [
['name' => 'SIMON Core', 'status' => 'online'],
['name' => 'WEB360', 'status' => 'online'],
['name' => 'Social Engine', 'status' => 'degraded'],
['name' => 'Accounting', 'status' => 'online'],
['name' => 'Analytics', 'status' => 'online'],
['name' => 'Forecast Engine', 'status' => 'warning'],
['name' => 'API Gateway', 'status' => 'online'],
['name' => 'Security Layer', 'status' => 'healthy'],
],
'server' => [
'php_version' => PHP_VERSION,
'environment' => 'Production',
'storage_mode' => 'JSON',
'last_sync' => date('Y-m-d H:i:s'),
]
];
/* ---------------------------------
LOAD DATA
--------------------------------- */
$projectsData = safe_read_json(PROJECTS_FILE, $defaultProjects);
$accountingData = safe_read_json(ACCOUNTING_FILE, $defaultAccounting);
$analyticsData = safe_read_json(ANALYTICS_FILE, $defaultAnalytics);
$systemData = safe_read_json(SYSTEM_FILE, $defaultSystem);
/* ---------------------------------
PROJECT METRICS
--------------------------------- */
$projects = $projectsData['projects'] ?? [];
$totalProjects = count($projects);
$projectCompletionAvg = avg(array_column($projects, 'completion'));
$totalBudget = array_sum(array_map(fn($p) => (float)($p['budget'] ?? 0), $projects));
$totalSpent = array_sum(array_map(fn($p) => (float)($p['spent'] ?? 0), $projects));
$totalOpenTodos = array_sum(array_map(fn($p) => (int)($p['todos_open'] ?? 0), $projects));
$totalDoneTodos = array_sum(array_map(fn($p) => (int)($p['todos_done'] ?? 0), $projects));
$todoCompletion = ($totalOpenTodos + $totalDoneTodos) > 0
? ($totalDoneTodos / ($totalOpenTodos + $totalDoneTodos)) * 100
: 0;
/* ---------------------------------
ACCOUNTING METRICS
--------------------------------- */
$revenueStreams = $accountingData['revenue_streams'] ?? [];
$expenses = $accountingData['expenses'] ?? [];
$totalRevenue = array_sum(array_map(fn($r) => (float)($r['amount'] ?? 0), $revenueStreams));
$totalExpenses = array_sum(array_map(fn($e) => (float)($e['amount'] ?? 0), $expenses));
$cashOnHand = (float)($accountingData['cash_on_hand'] ?? 0);
$monthlyRecurring = (float)($accountingData['monthly_recurring'] ?? 0);
$outstandingDebt = (float)($accountingData['outstanding_debt'] ?? 0);
$netMonthly = $totalRevenue - $totalExpenses;
/* ---------------------------------
ANALYTICS METRICS
--------------------------------- */
$traffic = $analyticsData['traffic'] ?? [];
$channels = $analyticsData['channels'] ?? [];
$topPages = $analyticsData['top_pages'] ?? [];
$visitsToday = (int)($traffic['visits_today'] ?? 0);
$visits7d = (int)($traffic['visits_7d'] ?? 0);
$visits30d = (int)($traffic['visits_30d'] ?? 0);
$bounceRate = (float)($traffic['bounce_rate'] ?? 0);
$conversionRate = (float)($traffic['conversion_rate'] ?? 0);
$avgSession = (float)($traffic['avg_session_minutes'] ?? 0);
/* ---------------------------------
SYSTEM METRICS
--------------------------------- */
$modules = $systemData['modules'] ?? [];
$server = $systemData['server'] ?? [];
$totalModules = count($modules);
$healthyModules = count(array_filter($modules, function ($m) {
return in_array(strtolower((string)($m['status'] ?? '')), ['online', 'healthy', 'good', 'stable'], true);
}));
$moduleHealthPercent = $totalModules > 0 ? ($healthyModules / $totalModules) * 100 : 0;
/* ---------------------------------
AI FORECAST ENGINE (simple heuristic)
--------------------------------- */
$runwayMonths = $totalExpenses > 0 ? $cashOnHand / $totalExpenses : 0;
$roiPercent = $totalSpent > 0 ? (($totalRevenue - $totalSpent) / $totalSpent) * 100 : 0;
$growthSignal = clamp(
($conversionRate * 8) +
((100 - $bounceRate) * 0.4) +
($projectCompletionAvg * 0.35) +
($moduleHealthPercent * 0.2),
0,
100
);
$forecastRevenue30 = $totalRevenue * (1 + ($growthSignal / 500));
$forecastRevenue90 = $totalRevenue * (1 + ($growthSignal / 220));
$priorityRecommendations = [];
if ($totalOpenTodos > 15) {
$priorityRecommendations[] = 'Reduce open task backlog by focusing only on high-value milestones this week.';
}
if ($totalExpenses > $totalRevenue) {
$priorityRecommendations[] = 'Expenses are outpacing revenue. Pause low-ROI spend and strengthen paid conversion tracking.';
}
if ($conversionRate < 3.5) {
$priorityRecommendations[] = 'Conversion rate is below target. Improve CTA placement, landing page clarity, and offer structure.';
}
if ($moduleHealthPercent < 85) {
$priorityRecommendations[] = 'System health is below preferred threshold. Stabilize degraded modules before expanding features.';
}
if ($projectCompletionAvg > 60 && $totalRevenue < 5000) {
$priorityRecommendations[] = 'Product maturity is improving. Shift more effort toward monetization and investor-ready reporting.';
}
if (empty($priorityRecommendations)) {
$priorityRecommendations[] = 'Current signals are stable. Continue building /projects, /accounting, and /analytics integration into /intelligence.';
}
/* ---------------------------------
UI FUNCTIONS
--------------------------------- */
function metric_card(string $title, string $value, string $sub = '', string $tone = 'neutral'): string
{
return '
' . h($title) . '
' . h($value) . '
' . h($sub) . '
';
}
function progress_bar(float $percent): string
{
$percent = clamp($percent, 0, 100);
return '
';
}
?>
= h(SIMON_APP_NAME . ' — ' . SIMON_APP_SUBTITLE) ?>
= h(SIMON_APP_NAME) ?>
= h(SIMON_APP_SUBTITLE) ?> — branded ecosystem dashboard for project tracking, accounting, analytics, AI forecasting, module monitoring, and next-step system guidance.
Projects
Accounting
Analytics
AI Forecast
System Health
= h(date('g:i A')) ?>
= h(date('l, F j, Y')) ?>
= metric_card('Active Projects', (string)$totalProjects, 'Tracked across /projects and ecosystem modules', 'neutral') ?>
= metric_card('Net Monthly', format_money($netMonthly), 'Revenue minus operating expense', $netMonthly >= 0 ? 'ok' : 'bad') ?>
= metric_card('Module Health', format_percent($moduleHealthPercent), $healthyModules . ' of ' . $totalModules . ' modules healthy', $moduleHealthPercent >= 85 ? 'ok' : 'warn') ?>
= metric_card('Growth Signal', format_percent($growthSignal), 'Blended AI confidence heuristic', $growthSignal >= 70 ? 'ok' : 'warn') ?>
Project Command Grid
/projects + cost tracking
| Project |
Status |
Phase |
Completion |
Budget |
Spent |
Todos |
= h((string)($project['name'] ?? 'Untitled')) ?>
Owner: = h((string)($project['owner'] ?? 'N/A')) ?> · Due: = h((string)($project['due_date'] ?? 'N/A')) ?>
|
= h((string)($project['status'] ?? 'unknown')) ?>
|
= h((string)($project['phase'] ?? '')) ?> |
= progress_bar((float)($project['completion'] ?? 0)) ?>
= h((string)($project['completion'] ?? 0)) ?>%
|
= h(format_money((float)($project['budget'] ?? 0))) ?> |
= h(format_money((float)($project['spent'] ?? 0))) ?> |
Open = h((string)($project['todos_open'] ?? 0)) ?>
/
Done = h((string)($project['todos_done'] ?? 0)) ?>
|
Average Completion
= h(format_percent($projectCompletionAvg)) ?>
Total Budget
= h(format_money($totalBudget)) ?>
Todo Completion
= h(format_percent($todoCompletion)) ?>
Accounting Overview
/accounting
= h((string)$row['name']) ?>
= h(format_money((float)$row['amount'])) ?>
Revenue stream
Revenue
= h(format_money($totalRevenue)) ?>
Expenses
= h(format_money($totalExpenses)) ?>
Cash On Hand
= h(format_money($cashOnHand)) ?>
Expense Breakdown
monthly ops
= h((string)$row['name']) ?>
= h(format_money((float)$row['amount'])) ?>
Operating expense
Recurring
= h(format_money($monthlyRecurring)) ?>
Debt
= h(format_money($outstandingDebt)) ?>
Runway
= h(number_format($runwayMonths, 1)) ?> mo
Traffic Analytics
/analytics
Today
= h((string)$visitsToday) ?>
7 Days
= h((string)$visits7d) ?>
30 Days
= h((string)$visits30d) ?>
Bounce Rate
= h(format_percent($bounceRate)) ?>
Conversion
= h(format_percent($conversionRate)) ?>
Avg Session
= h(number_format($avgSession, 1)) ?>m
Top Pages
site performance
= h((string)$page['path']) ?>
= h(number_format((int)$page['views'])) ?> views
Tracked page traffic
Channel Mix
traffic sources
= h((string)$channel['name']) ?>
= h(number_format($channelVisits)) ?>
System Module Health
/system monitor
= h((string)$module['name']) ?>
= h((string)($module['status'] ?? 'unknown')) ?>
Live ecosystem status
AI Forecast Engine
/intelligence
ROI Signal
= h(format_percent($roiPercent)) ?>
30 Day Forecast
= h(format_money($forecastRevenue30)) ?>
90 Day Forecast
= h(format_money($forecastRevenue90)) ?>
| PHP Version |
= h((string)($server['php_version'] ?? PHP_VERSION)) ?> |
| Environment |
= h((string)($server['environment'] ?? 'Production')) ?> |
| Storage |
= h((string)($server['storage_mode'] ?? 'JSON')) ?> |
| Last Sync |
= h((string)($server['last_sync'] ?? date('Y-m-d H:i:s'))) ?> |
| Data Directory |
= h(DATA_DIR) ?> |